//
//  MainTabBarViewController.swift
//  JLsmallDay
//
//  Created by sun on 16/1/4.
//  Copyright © 2016年 sun. All rights reserved.
//

import UIKit

class MainTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        tabBar.backgroundImage = UIImage(named: "tabbar")
        self.tabBar.translucent = false
        setupAllChildViewController()
    }

    /**
     添加所有子控制器
     */
    private func setupAllChildViewController(){
        tabBarAddChildViewController(ExploreViewController(), title: "探店", norImage: "recommendation_1", seleImage: "recommendation_2")
        tabBarAddChildViewController(ExperienceViewController(), title: "体验", norImage: "broadwood_1", seleImage: "broadwood_2")
        tabBarAddChildViewController(ClassifyViewController(), title: "分类", norImage: "classification_1", seleImage: "classification_2")
        tabBarAddChildViewController(MeViewController(), title: "我的", norImage: "my_1", seleImage: "my_2")
    }
    /**
     tabBar添加自控制器
     */
    private func tabBarAddChildViewController(vc: UIViewController , title: String , norImage: String , seleImage: String){
        vc.tabBarItem = UITabBarItem(title: title, image: UIImage(named: norImage), selectedImage: UIImage(named: seleImage))
        vc.title = title
         let nav = MainNavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
}
